package com.isoftstone.guodian.purApproval.control;

import com.isoftstone.guodian.demo.service.TFultbpurchasingapplyService;
import com.isoftstone.guodian.entity.TFultbpurchasingapplyEntity;
import com.isoftstone.guodian.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class TFultbpurchasingapplyControl5 {
    @Autowired
    private TFultbpurchasingapplyService tfultbpurchasingapplyService;

    @RequestMapping("/hateee")
    public String updateEmpLifultbpurchasingapply2(String organName, Integer pageNow, Model model) throws Exception {

        StringBuffer a = new StringBuffer();
        a.append(" and billnumber like '%" + organName + "%'");
        TFultbpurchasingapplyEntity entity = new TFultbpurchasingapplyEntity();
        try {
            PageUtils page = new PageUtils();
            if (pageNow == null) {
                pageNow = 1;
            }
            entity.setWhereSql(a);
            List<TFultbpurchasingapplyEntity> list = tfultbpurchasingapplyService.selectForPage(entity);
            page.setPageNow(pageNow);
            page.setTotal(list.size());
            if(page.getPageNow()>=page.getTotalPage()){
                page.setPageNow(page.getTotalPage());
            }
            if(page.getPageNow()<=0){
                page.setPageNow(1);
            }
            entity.setPageUtils(page);

            model.addAttribute("rows", list);
            model.addAttribute("page",page);
        } catch (Exception e) {
            e.printStackTrace();
        }
            return "/demo/demo_cgsqsp.jsp";

    }

}
